﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace Kokomo.Mirror.PeFormat
{
	[Description("Optional Header (64-bit)")]
	public class OptionalHeader64 : PeHeaderStruct, IOptionalHeader
	{
		public static readonly int StructSize = 0xF0;

		[TypeConverter(typeof(HexConverter))]
		public ushort Magic { get; private set; }

		public SmallVersion LinkerVersion { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint SizeOfCode { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint SizeOfInitializedData { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint SizeOfUninitializedData { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint AddressOfEntryPoint { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint BaseOfCode { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public long ImageBase { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint SectionAlignment { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint FileAlignment { get; private set; }

		public Version OperatingSystemVersion { get; private set; }
		public Version ImageVersion { get; private set; }
		public Version SubsystemVersion { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint Win32VersionValue { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint SizeOfImage { get; set; }

		[TypeConverter(typeof(HexConverter))]
		public uint SizeOfHeaders { get; set; }

		[TypeConverter(typeof(HexConverter))]
		public uint CheckSum { get; private set; }

		public Subsystem Subsystem { get; private set; }
		public DllCharacteristics DllCharacteristics { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public long SizeOfStackReserve { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public long SizeOfStackCommit { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public long SizeOfHeapReserve { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public long SizeOfHeapCommit { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint LoaderFlags { get; private set; }

		public uint NumberOfRvaAndSizes { get; private set; }

		[SerializedArray(ArrayLengthEncoding.Fixed, 16)]
		public DataDirectoryEntry[] DataDirectory { get; private set; }
	}
}
